package com.bianxianmao.myinfo.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bianxianmao.R;
import com.bianxianmao.base.BaseFragment;
import com.bianxianmao.duobao.activity.RechargeActivity;
import com.bianxianmao.myinfo.activity.CommonQuestionActivity;
import com.bianxianmao.myinfo.activity.DuobaoRecordActivity;
import com.bianxianmao.myinfo.activity.LetterActivity;
import com.bianxianmao.myinfo.activity.MyRedPocketActivity;
import com.bianxianmao.myinfo.activity.MyshowListActivity;
import com.bianxianmao.myinfo.activity.PrizeRecordActivity;
import com.bianxianmao.myinfo.activity.RechargeRecordActivity;
import com.bianxianmao.myinfo.activity.SettingActivity;
import com.bianxianmao.myinfo.activity.ShoppingAddressActivity;
import com.bianxianmao.myinfo.activity.UserAccountActivity;


/**
 * Created by Administrator on 2017/7/7 0007.
 * 我的fragment
 */

public class MyinfoFragment extends BaseFragment implements View.OnClickListener {

    private TextView showlist;
    private TextView rechargerecord;
    private TextView shoppingaddress;
    private TextView setting;
    private TextView questions;
    private ImageView icon;
    private ImageView letter;
    private Button recharge;
    private TextView duobaorecord;
    private TextView prizerecord;
    private TextView myredpacket;
    boolean login;

    @Override
    public View initView() {
        View view = View.inflate(mContext, R.layout.fragment_myinfo, null);
        icon = (ImageView) view.findViewById(R.id.iv_icon);
        letter = (ImageView) view.findViewById(R.id.iv_letter);
        recharge = (Button) view.findViewById(R.id.btn_recharge);
        duobaorecord = (TextView) view.findViewById(R.id.tv_duobao_record);
        prizerecord = (TextView) view.findViewById(R.id.tv_prizecord);
        myredpacket = (TextView) view.findViewById(R.id.tv_myredpacket);
        showlist = (TextView) view.findViewById(R.id.tv_showlist);
        rechargerecord = (TextView) view.findViewById(R.id.tv_rechage_record);
        shoppingaddress = (TextView) view.findViewById(R.id.tv_shoppingaddress);
        setting = (TextView) view.findViewById(R.id.tv_setting);
        questions = (TextView) view.findViewById(R.id.tv_commonquestions);
        return view;
    }

    @Override
    public void initData() {
        icon.setOnClickListener(this);
        letter.setOnClickListener(this);
        recharge.setOnClickListener(this);
        duobaorecord.setOnClickListener(this);
        prizerecord.setOnClickListener(this);
        myredpacket.setOnClickListener(this);
        showlist.setOnClickListener(this);
        rechargerecord.setOnClickListener(this);
        shoppingaddress.setOnClickListener(this);
        setting.setOnClickListener(this);
        questions.setOnClickListener(this);
//        boolean login = (boolean) SPutils.get(getActivity(), "login", false);
//        if (!login){
//                startActivity(new Intent(getContext(), LoginActivity.class));
//        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_icon://头像
                Intent intent = new Intent(getActivity(), UserAccountActivity.class);
                startActivity(intent);
                break;
            case R.id.iv_letter://消息
                Intent letterintent = new Intent(getActivity(), LetterActivity.class);
                startActivity(letterintent);
                break;
            case R.id.btn_recharge://充值
                Intent rechargeintent = new Intent(getActivity(), RechargeActivity.class);
                startActivity(rechargeintent);
                break;
            case R.id.tv_duobao_record://夺宝记录
                Intent duobaointent = new Intent(getActivity(), DuobaoRecordActivity.class);
                startActivity(duobaointent);
                break;
            case R.id.tv_prizecord://中奖记录
                Intent prizecordintent = new Intent(getActivity(), PrizeRecordActivity.class);
                startActivity(prizecordintent);
                break;
            case R.id.tv_myredpacket://我的红包
                Intent myredpacketintent = new Intent(getActivity(), MyRedPocketActivity.class);
                startActivity(myredpacketintent);
                break;
            case R.id.tv_showlist://我的晒单
                Intent showlistintent = new Intent(getActivity(), MyshowListActivity.class);
                startActivity(showlistintent);
                break;
            case R.id.tv_rechage_record://充值记录
                Intent recordintent = new Intent(getActivity(), RechargeRecordActivity.class);
                startActivity(recordintent);
                break;
            case R.id.tv_shoppingaddress://收货地址
                Intent shoppingaddressintent = new Intent(getActivity(), ShoppingAddressActivity.class);
                startActivity(shoppingaddressintent);
                break;
            case R.id.tv_setting://设置
                Intent settingintent = new Intent(getActivity(), SettingActivity.class);
                startActivity(settingintent);
                break;
            case R.id.tv_commonquestions://常见问题
                Intent commonquestionsintent = new Intent(getActivity(), CommonQuestionActivity.class);
                startActivity(commonquestionsintent);
                break;
        }
    }
}
